package com.yanqu.road.server.cmd.activity.peakseacraft;

import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.PeakSeacraftProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.peakseacraft.PeakSeacraftMgr;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.server.protocol.CrossProtocol;

@Cmd(code = CrossProtocol.C_PEAK_SEACRAFT_DONATION_SHIP, desc = "海上争霸 南海丝路 捐献")
public class CrossPeakSeacraftDonationShipCmd extends CrossUnionCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        PeakSeacraftProto.PeakSeacraftDonationShipGameToCrossMsg reqMsg = PeakSeacraftProto.PeakSeacraftDonationShipGameToCrossMsg.parseFrom(packet.getBytes());
        long userId = packet.getPlayerId();
        if (reqMsg.hasPlayerInfo()) {
            CrossUserMgr.updateUserBaseInfo(userId, PlayerBasePb.parseToUserBaseInfo(reqMsg.getPlayerInfo()));
        }
        PeakSeacraftMgr.donationShip(userId, serverId, reqMsg.getActivityId(), reqMsg.getUnionId(), reqMsg.getDonateExp(), reqMsg.getType(), reqMsg.getCost());
    }

    @Override
    public void sendData() {

    }
}
